import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictServer extends UdpEchoServer{
    Map<String,String> dict = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        // 调用父类构造方法这句代码，必须放到子类构造方法的第一行
        super(port);

        dict.put("hello","你好");
        dict.put("cat","小猫");
        dict.put("dog","小狗");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"没有找到该单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer dictServer = new UdpDictServer(9090);
        dictServer.start();
    }
}
